from .MyLogger import MyLogger
from .Instruction import Instruction

class UIInstruction(Instruction):
    def __init__(self) -> None:
        self.instSymbol:str = ''
        self.helpInfo:str = ''
        self.args:str = ''

    def GetHelp(self) -> str:
        usage = ''
        if self.args:
            usage = '\n' + ' ' * 6 + 'usage:    ' + self.instSymbol + ' ' + self.args
        return f'{self.instSymbol:<14}  {self.helpInfo}{usage}'

g_uiInstTable:dict[str, UIInstruction] = {}

def ui_auto_add(cls):
    inst:UIInstruction = cls()
    g_uiInstTable[inst.instSymbol] = inst
    return cls

def GetInstTable():
    return g_uiInstTable